﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Layout/SiteNoHead.master"
	AutoEventWireup="true" CodeBehind="EditArticle.aspx.cs" Inherits="IService.Admin.Pages.EditArticle" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	新闻编辑
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="HeadContent" runat="server">
	<base target="_self" />
	<link href="../uploadify/uploadify.css" rel="stylesheet" type="text/css" />
	<link href="../Style/zTreeStyle.css" rel="stylesheet" type="text/css" />
	<script src="../uploadify/swfobject.js" type="text/javascript"></script>
	<script src="../uploadify/jquery.uploadify.v2.1.4.min.js" type="text/javascript"></script>
	<script src="../Script/jquery.ztree.core-3.0.min.js" type="text/javascript"></script>
	<script src="../Script/jquery.ztree.exedit-3.0.min.js" type="text/javascript"></script>
	<script src="../Script/jquery.ztree.excheck-3.0.min.js" type="text/javascript"></script>
	<script type="text/javascript">
		var setting = {
			data: {
				simpleData: {
					enable: true,
					idKey: "id"
				}
			},
			view: {
				showIcon: true,
				showLine: false
			},
			callback: {
				beforeClick: zTreeBeforeClick,
				onClick: zTreeOnClick
			}
		};
		function zTreeBeforeClick(treeId, treeNode, clickFlag)
		{
			return !(treeNode.isParent);
		};
		function zTreeOnClick(event, treeId, treeNode)
		{
			$("#<%=HidTypeShow.ClientID %>").val(treeNode.id);
			
		};
		$(function ()
		{
			$('#fileupload').uploadify({
				'uploader': '../uploadify/uploadify.swf',
				'script': '../../Handler/UploadHandler.ashx',
				'cancelImg': '../uploadify/cancel.png',
				'folder': '../../UploadFile/Article',
				'queueID': 'fileQueue',
				'auto': false,
				'multi': false,
				'sizeLimit': 1024 * 1024,
				'simUploadLimit': 5,
				'fileExt': '*.jpg;*.gif;*.png',
				'fileDesc': 'Image Files',
//				onComplete: ImageComplete,
				onError: function () { alert("图片上传失败！") }
			});
			//绑定新闻类别
			var newdata = "null";
			$.ajax({
				asnyc: true,
				url: "/handler/TypeHandler.ashx?time=" + new Date().getTime(),
				data: "registerSystem=NewsManagement",
				success: function (html)
				{
					newdata = eval('(' + html + ')');
					$.fn.zTree.init($("#treeDemo"), setting, newdata);
					var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
					var currentTypeid = $("#<%=HidTypeShow.ClientID %>").val().replace(' ', '');
					if (currentTypeid !== '')
					{
						var node = treeObj.getNodeByParam("id", currentTypeid, null);
						treeObj.selectNode(node, false);
					} else
					{
						//alert("此新闻未选择类别！");
					}
				}
			});
		});

		function checkInput()
		{
			var newsTitle = $("#<%=NewsTitle.ClientID %>").val().replace(' ', '');
			var createPeople = $("#<%=CreatePeople.ClientID %>").val().replace(' ', '');
			var NewsType = $("#<%=HidTypeShow.ClientID %>").val().replace(' ', '');
			var errorLbl = $("#<%=LblError.ClientID %>");
			if (newsTitle == '')
			{
				errorLbl.html("<font color='red'>新闻标题不能为空！</font>");
				return false;
			} else if (NewsType == '')
			{
				errorLbl.html("<font color='red'>请选择新闻类别！</font>");
				return false;
			} else if (createPeople == '')
			{
				errorLbl.html("<font color='red'>发布人不能为空！</font>");
				return false;
		    }

			return true;
		}
	</script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="SubTitle" runat="server">
	新闻编辑
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="MainContent" runat="server">
	<asp:Button runat="server" CssClass="button" Text="发布" OnClientClick="return checkInput();"
		ID="Button1" OnClick="BtnEditArticle_Click" />
	<table class="news_table" border="1">
		<thead>
			<tr>
				<th>
					新闻标题：
				</th>
				<td>
					<asp:TextBox CssClass="newstxt" MaxLength="80" ID="NewsTitle" runat="server"></asp:TextBox>
					<span class="red">*</span>
					<asp:Label ID="LblError" runat="server"></asp:Label>
				</td>
			</tr>
		</thead>
		<tbody>
			<tr>
				<th>
					新闻类型：
				</th>
				<td>
					<ul id="treeDemo" class="ztree">
					</ul>
					<asp:HiddenField ID="HidTypeShow" runat="server" />
				</td>
			</tr>
			<tr>
				<th>
					发布者：
				</th>
				<td>
					<asp:TextBox CssClass="newstxt" ReadOnly="true" ID="CreatePeople" runat="server"></asp:TextBox>
					<span class="red">*</span>
				</td>
			</tr>
			<%--<tr>
				<th>
					新闻图片：
				</th>
				<td>
					<asp:Image ID="previewPic" Width="200" Height="200" runat="server" />
					<div id="fileQueue">
					</div>
					<input id="fileupload" name="fileupload" type="file" />
					<p>
						<a href="javascript:$('#fileupload').uploadifyUpload();">上传</a> <a href="javascript:$('#fileupload').uploadifyClearQueue();">
							取消</a>
					</p>
					<asp:HiddenField ID="ArticlePic" runat="server" />
				</td>
			</tr>--%>
			<tr>
				<th>
					是否在外网显示:
				</th>
				<td>
					<asp:CheckBox ID="ChkShowWebSite" runat="server" />
					<span class="red">*</span>
				</td>
			</tr>
			<tr>
				<th>
					新闻：
				</th>
				<td>
					<CKEditor:CKEditorControl ID="newsContentCKeditor" runat="server">
					</CKEditor:CKEditorControl>
				</td>
			</tr>
			<tr>
				<th>
					发布：
				</th>
				<td>
					<asp:Button runat="server" CssClass="button" OnClientClick="return checkInput();"
						Text="发布" ID="BtnEditArticle" OnClick="BtnEditArticle_Click" />
				</td>
			</tr>
		</tbody>
	</table>
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="MainBody" runat="server">
</asp:Content>
